/**
 * Copyright (c) 2008 Trent Hoeppner
 * 
 * This file is part of BillCalc.
 * 
 * BillCalc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BillCalc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with BillCalc.  If not, see <http://www.gnu.org/licenses/>.
 **/

package com.trentech.billcalc.event;

/**
 * InvalidResult holds localized and English error message associated with a 
 * property of an Event.  Instances of this are generated by calling 
 * {@link Event#validate(String, Object, FinanceManager)}.
 * 
 * @author Trent Hoeppner
 */
public class InvalidResultException extends Exception {
    /**
     * Required for serialization.
     */
    private static final long serialVersionUID = 7017811958905242748L;
    
    
    /**
     * The Event that generated this.
     */
    private final Event source;
    
    
    /**
     * The name of the property that is invalid.
     */
    private final String propertyName;
    
    
    /**
     * The error message for the user.
     */
    private final String errorMessage;
    

    /**
     * Constructor for InvalidResultException.
     * 
     * @param   source          the Event that generated this.  Cannot be null.
     * @param   propertyName    the name of the property that is invalid.  
     *                          Cannot be null or empty.
     * @param   errorMessage    the error message to display to the user.
     */
    public InvalidResultException(Event source, String propertyName, String errorMessage) {
        this.source = source;
        this.propertyName = propertyName;
        this.errorMessage = errorMessage;
    }

    
    /**
     * Returns the Event that generated this.
     * 
     * @return  the Event that generated this.  Will not be null.
     */
    public Event getSource() {
        return source;
    }

    
    /**
     * Returns the name of the property that is invalid.
     * 
     * @return  the name of the property that is invalid.  Will not be null or 
     *          empty.
     */
    public String getPropertyName() {
        return propertyName;
    }

    
    /**
     * Returns the error message to display to the user.
     * 
     * @return  the error message to display to the user.  Will not be null or 
     *          empty.
     */
    public String getErrorMessage() {
        return errorMessage;
    }
}
